import java.net.*;
import java.io.*;

public class TCPServer {
    
    public static void main(String args[]){ 
        int numClient=0;
        
        try{
            int serverPort = 6000;
            System.out.println("A escuta no porto 6000");
            ServerSocket listenSocket = new ServerSocket(serverPort);
            System.out.println("Listen Socket= "+listenSocket);
            
            while(true){
                Socket clientSocket = listenSocket.accept(); //BLOQUEANTE
                System.out.println("CLIENT_SOCKET (created at accept())="+clientSocket);
                numClient++;
                new Connection(clientSocket, numClient);
            }
        }catch(IOException e){
            System.out.println("Listen:" + e.getMessage());
        }      
    }
    
}
